export default {
	data() {
		return {
			phone: '',
			password: '',
			tip: '',
			//是否显示加载动画
			show: false
		}
	},
	onLoad() {

	},
	methods: {
		//登录
		login() {
			this.show = true;
			this.$request('/User/login', {
				// 传参参数名：参数值,如果没有，就不需要传
				"phone": this.phone,
				"password": this.password
			}).then(res => {

				if (res.code == 200) {
					uni.setStorage({
						key: 'userId',
						data: res.data.userId,
						success: function() {

						}
					});
					uni.setStorage({
						key: 'userUuid',
						data: res.data.userUuid,
						success: function() {
					
						}
					});
					uni.setStorage({
						key: 'phone',
						data: res.data.phone,
						success: function() {
					
						}
					});
					uni.setStorage({
						key: 'email',
						data: res.data.email,
						success: function() {
					
						}
					});
					uni.setStorage({
						key: 'token',
						data: res.msg.split("|token:")[1],
						success: function() {

						}
					});
					uni.setStorage({
						key: 'headImg',
						data: res.data.headImg,
						success: function() {

						}
					});
					uni.setStorage({
						key: 'nickName',
						data: res.data.nickName,
						success: function() {

						}
					});
					uni.setStorage({
						key: 'dataLocation',
						data: res.data.dataLocation,
						success: function() {
					
						}
					});

					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/index/index',
						});
						this.show = false;
					}, 500);
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 2000
					});
					this.show = false;
				}
			})
		},
		//前往注册
		enroll() {
			uni.navigateTo({
				url: '/pages/enroll/enroll',
			});
		}
	}
}
